<template>
	<view class="opinion">
		<view class="opinion_title">评分</view>
		<view class="opinion_rate">
			<uni-rate :size="18" activeColor="#e9a944" allow-half :value="dataobj.fraction" @change="onChange" />
			<text class="font14 font-969696">{{dataobj.fraction}}分</text>
		</view>
		<view class="opinion_title">意见反馈</view>
		<textarea @input="Ondescribe" class="textarea_test" placeholder-class="placeholderClass"
			placeholder="请留下您宝贵的意见和建议（不得超过300字）" maxlength="300" :value="dataobj.content" />
		<!-- 提交 -->
		<view class="qx_button">
			<view @click="Onadd" class="font-323232 font16">提交</view>
		</view>
	</view>



</template>

<script>
	export default {
		onLoad: function(options) {
			if (options.type == 'tw') {
				this.dataobj.type = 'consultation_order'
			}
			if (options.type == 'store'||options.type == 'sp') {
				this.dataobj.type = 'consultation_video_order'
			}
			if (options.type == 'report') {
				this.dataobj.type = 'consultation_report_order'
			}
			this.dataobj.order_id = options.id
		},
		data() {
			return {
				dataobj: {
					fraction: 5,
					content: '',
					type: '',
					order_id: null
				}
			}
		},
		methods: {
			//评分
			onChange(e) {
				this.dataobj.fraction = e.value
			},
			//评论
			Ondescribe(e) {
				this.dataobj.content = e.detail.value
			},
			//提交
			Onadd() {
				this.$Http({
					url: 'addComment',
					show: true,
					type: 'POST',
					data: this.dataobj,
				}).then(res => {
					if (res.code == 1) {
						uni.showModal({
							title: '温馨提示',
							confirmText: '确定',
							confirmColor: '#b8875c',
							showCancel: false,
							content: '评论成功~',
							success: function(res1) {
								console.log('789797897987')
								if (res1.confirm) {
									uni.switchTab({
										url: '/pages/my/index',
									})
								}
							}
						});
					}
				});
			}
		}
	}
</script>

<style>
	.opinion_title {
		padding-left: 35rpx;
		font-size: 32rpx;
		color: #323232;
		font-weight: 700;
		margin-top: 50rpx;
	}

	.opinion_rate {
		display: flex;
		align-items: center;
		padding: 32rpx 26rpx;
	}

	.opinion_rate view {
		margin-right: 10rpx;
	}

	.textarea_test {
		width: 680rpx;
		height: 360rpx;
		background-color: #f9f9f9;
		border-radius: 5rpx;
		margin: 40rpx 35rpx 62rpx 35rpx;
		padding: 32rpx 26rpx;
	}

	/* 提交 */
	.qx_button {
		width: 750rpx;
		height: 120rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		background-color: #f9f9f9;
		z-index: 2;
	}

	.qx_button view {
		width: 650rpx;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		margin-left: 50rpx;
		margin-top: 20rpx;
		background-color: #6bcbb6;
		color: #fff;
	}

	.placeholderClass {
		font-size: 28rpx;
		color: #989898;
		line-height: 50rpx;
	}
</style>
